<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>对象语法</title>
<style>
  div div {
    width: 100px;
    height: 100px;
  }
  .active {
    background-color: green;
  }
  .border {
    border: 2px solid red;
  }
</style>
</head>
<body>

<div id="app">
  <div :class="{active: isActive, border: hasBorder}"></div>
  <button @click="chgStyle">切换背景色</button>
  <button @click="chgBorder">切换边框</button>
</div>

<script src="../lib/vue.js"></script>
<script>
  let vm = new Vue({
    el: '#app',
    data: {
      isActive: true,
      hasBorder: false
    },
    methods: {
      chgStyle() {
        this.isActive = !this.isActive;
      },
      chgBorder() {
        this.hasBorder = !this.hasBorder
      }
    }
  })
</script>

</body>
</html>